/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package stendcontrol;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import services.CountOutputStream;

/**
 *
 * @author RATSUF
 */
public class ExperimentOutputStream extends ObjectOutputStream {

    Experiment exp;
    private ArrayList<AbstractMessage> copy_messages = new 
            ArrayList<AbstractMessage>();
    private int n = 0;
    OutputStream eos;

    /**
     *
     * @param eoos
     */
    public ExperimentOutputStream(OutputStream eos) throws IOException {
        super(eos);
        this.eos = eos ;
    }
    
    
    /**
     *
     */
    public void writeExp(Experiment exp) throws IOException {
        
      // CountOutputStream cos = (CountOutputStream) eos ; 
        exp.clearCache();
        
        this.writeObject(exp.getExpName());
       // System.out.println("Bytes count 1  : " + cos.getCount());
        this.writeInt(exp.getCountMeasures());
        System.out.println("Exp count measures " +exp.getCountMeasures() );
      //  System.out.println("Bytes count 2 : " + cos.getCount());
        this.writeObject(exp);
        
        /*while (this.copy_messages.size() != exp.getCountMessage()) {
            this.copy_messages.add(exp.getMessage(n++));
        }
        n=0;
      //  System.out.println("Bytes count 3 : " + cos.getCount()) ;    

        this.writeObject(copy_messages);*/
      //  System.out.println("Bytes count 4  : " + cos.getCount());

    }
}
